package com.bw.services.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bw.services.R
import com.bw.services.entity.CarManage

class Car_ManageAdapter(private val itemLIst:List<CarManage>): RecyclerView.Adapter<Car_ManageAdapter.ViewHolder>() {
    class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val tvLicense: TextView = view.findViewById(R.id.tv_license)
        val tvOwner: TextView = view.findViewById(R.id.tv_owner)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_car_manage, parent, false)
    return ViewHolder(view)
    }

    override fun getItemCount(): Int = itemLIst.size

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val item =itemLIst[position]
        holder.tvLicense.text = item.licensePlate
        holder.tvOwner.text = item.ownerName
    }

}